package org.madason.humanresources.datalayer;

import java.sql.Connection;

import javax.naming.InitialContext;
import javax.sql.DataSource;

public class DBUtil 
{
	public static Connection getConn()
	{
		try
		{
			InitialContext ctx = new InitialContext();
			DataSource datasource = (DataSource) ctx.lookup("java:HR-DS");
			return datasource.getConnection();
		}
		catch (Exception e)
		{
			try
			{
				Class.forName("oracle.jdbc.driver.OracleDriver");
				return java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "HR", "HR");
			}
			catch (Exception ex)
			{
				ex.printStackTrace();
				return null;
			}
		}
	}
}
